package com.xzy.dto;

import com.xzy.util.ChineseUtil;
import com.xzy.util.RandomUtils;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.*;

/**
 * @author xzy.xiao
 * @date 2022/7/7  10:12
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class UserDto {
    private String userId;
    private String username;
    private String realName;
    private Integer age;
    private String sex;
    private Date createTime;

    public static UserDto getRandomUser() {
        String userId = RandomUtils.getRandomString(11, RandomUtils.NUMBER_SET);
        String username = RandomUtils.getRandomString(5, RandomUtils.LETTER_SET);
        String realName = ChineseUtil.getRandomChineseName();
        Integer age = new Random().nextInt(100);
        String sex = RandomUtils.getRandomString(1, 'm', 'w');
        Date createTime = new Date();
        return new UserDto(userId, username, realName, age, sex, createTime);
    }

    public static List<UserDto> getRandomUserList(int numberOfUser) {
        if (numberOfUser <= 0) {
            return Collections.emptyList();
        }

        List<UserDto> userList = new ArrayList<>(numberOfUser);
        for (int i = 0; i < numberOfUser; i++) {
            userList.add(getRandomUser());
        }
        return userList;
    }
}
